package de.hszg.wjl.datacore.model;

import static org.junit.Assert.*;

import org.junit.Test;

public class MultiChoiceQuestionTest extends QuestionTest<MultiChoiceQuestion> {

	@Test
	public void testGetAwnser() {

		MultiChoiceQuestion question = new MultiChoiceQuestion();
		question.getAnswers().add("1");
		assertTrue(question.getAnswer().equals("1"));
		question.getAnswers().add("3");
		assertTrue(question.getAnswer().equals("1,3")
				|| question.getAnswer().equals("3,1"));

	}

	@Test
	public void testXMLParsing() {
		MultiChoiceQuestion question = createQuestion();
		assertTrue(question.getType() == QuestionType.MULTICHOICE);
		assertTrue(question.getID().equals("4"));
		assertTrue(question.isRequired());
		assertTrue(question.getText().equals(
				"What programming languages are you interested in?"));

		assertTrue(question.getOptions().get("4").equals("C++"));
		assertTrue(question.getOptions().get("5").equals("Scala"));
		assertTrue(question.getOptions().get("6").equals("Java"));

	}

	@Override
	protected String getQuestionXML() {
		return "<question type='multichoice' required='true' id='4'><text>What programming languages are you interested in?</text><choices><choice id='4'>C++</choice><choice id='5'>Scala</choice><choice id='6'>Java</choice></choices></question>";
	}

}
